package com.lsj.threadtest;

public class MyThread1 extends Thread{
    private String name;

    public MyThread1(String name){
        this.name = name;
    }
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("name:" + i);
            try {
                sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }

    public static void main(String[] args) {
        MyThread1 mt1 = new MyThread1("线程1");
        MyThread1 mt2=new MyThread1("线程2");
        //直接调用run方法 在当前线程内运行
//        mt1.run();
        //start方法新建线程 在新线程内运行
        mt1.start();
        mt2.start();
        //不能重复start
//        MyThread1 mt2=mt1;
//        mt2.start();
    }
}

